package cn.tedu.hotel.preload;

import cn.tedu.hotel.service.IRoomService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;

/**
 *  开机后自动加载缓存数据
 */
@Slf4j
public class CacheLoader implements ApplicationRunner {

    @Autowired
    private IRoomService roomService;

    public CacheLoader(){
        log.debug("创建ApplicationRunner: CacheLoader");
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.debug("CacheLoader.run()");
        log.debug("加载房间数据到缓存……");
        roomService.loadRoomToCache();
    }
}
